package com.ifast.sys.util;

import javax.servlet.http.HttpServletRequest;

import org.apache.commons.lang.StringUtils;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.Subject;


/**
 * 权限辅助类
 * 
 * @author cs Jan 24, 2013
 */
public class PermissUtil {
	
	/**
	 * 校验用户是否有某个角色
	 * @param roleName
	 * @return
	 */
	public static boolean hasRole(String roleName) {
		// 获取用户信息
		Subject currentUser = SecurityUtils.getSubject();
		boolean hasRole = currentUser.hasRole(roleName);
		return hasRole;
	}

	/**
	 * 校验当前用户是否有某个按钮类型权限
	 * @param permission
	 * @return
	 */
	public static boolean hasPermission(String permission) {
		// 获取用户信息
		Subject currentUser = SecurityUtils.getSubject();
		return currentUser.isPermitted(permission);// 判断是否有权限
	}



}
